#include "../include/header.h"

void Change(char *str, int low, int high)
{
    char temp;
    while (low < high) {
        temp = str[low];
        str[low] = str[high];
        str[high] = temp;
        low++;
        high--;
    }
}

void Convert(char *str)
{
    if (NULL == str)
        return ;

    int strLen = strlen(str);

    Change(str, 0, strLen - 1);

    cout << "After change first:" << endl;
    puts(str);

    int forehead = 0;
    int last = 0;

    while (forehead < strLen) {
        if (' ' == str[forehead] && last < forehead) {
            Change(str, last, forehead - 1);
            last = forehead + 1;
        }
        forehead++;
    }
    if (last < forehead)
        Change(str, last, forehead - 1);

}

#define SIZE_STR  50
void TestForTen()
{
    char str[SIZE_STR] ;
    cout << "Please input your string :" << endl;
    gets(str);
    Convert(str);
    cout << "The string after convet!"  << endl << str << endl;
}
